import java.util.ArrayList;
import java.util.List;

public class Node {

	public int x;
	public int y;
	public boolean visited;
	public boolean colour;
	public List<Node> edges = new ArrayList<Node>();
	public Graph graph;
	public int bestEdgeOfNode;
	public int orientation;
	public int doorDirection;
	public int up;
	public int left;
	public int down;
	public int right;
	public Node parentNode;

	public Node(int x, int y) {
		this.x = x;
		this.y = y;
		this.visited = false;
		this.colour = false;
	}

	public Node() {
		// TODO Auto-generated constructor stub
	}

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

	public boolean isVisited() {
		return visited;
	}

	public void setVisited(boolean visited) {
		this.visited = visited;
	}

	public boolean isColour() {
		return colour;
	}

	public void setColour(boolean colour) {
		this.colour = colour;
	}

	public int getBestEdgeOfNode() {
		return bestEdgeOfNode;
	}

	public void setBestEdgeOfNode(int bestEdgeOfNode) {
		this.bestEdgeOfNode = bestEdgeOfNode;
	}

	public int getOrientation() {
		return orientation;
	}

	public void setOrientation(int orientation) {
		this.orientation = orientation;
	}

	public int getDoorDirection() {
		return doorDirection;
	}

	public void setDoorDirection(int doorDirection) {
		this.doorDirection = doorDirection;
	}

	public List<Node> getEdges() {
		return edges;
	}

	public void setEdges(List<Node> edges) {
		this.edges = edges;
	}

	public Node getParentNode() {
		return parentNode;
	}

	public void setParentNode(Node parentNode) {
		this.parentNode = parentNode;
	}

	public Graph getGraph() {
		return graph;
	}

	public void setGraph(Graph graph) {
		this.graph = graph;
	}

	public String toString() {
		return "Node [x=" + x + ", y=" + y + ", visited=" + visited
				+ ", colour=" + colour + "]";
	}

	public Node setEdges(int newOrientation) throws InterruptedException {
		int newX = this.getX();
		int newY = this.getY();
		Node nextNode = null;
		switch (newOrientation) {
		case 0:
			nextNode = graph.nodes[(newY + 1)][newX];
			break;
		case 1:
			nextNode = graph.nodes[newY][(newX + 1)];
			break;
		case 2:
			nextNode = graph.nodes[(newY - 1)][newX];
			break;
		case 3:
			nextNode = graph.nodes[newY][(newX - 1)];
			break;
		}

		if ((!(edges.contains(nextNode))) || (nextNode == null)) {
			edges.add(nextNode);
		}
		return nextNode;
	}
}
